package com.niit.mall.order.listener;


import com.niit.mall.order.service.IOrderService;
import lombok.RequiredArgsConstructor;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * @BelongsProject: pardo_mall_backend
 * @BelongsPackage: com.niit.mall.order.listener
 * @Author: ChuXuan
 * @CreateTime: 2025-06-08  02:33
 * @Description: 支付状态监听
 * @Version: 1.0
 */

@Component
@RequiredArgsConstructor
public class PayStatusListener {
	
	private final IOrderService orderService;
	
	@RabbitListener(bindings = @QueueBinding(
			value = @Queue(name = "order.pay.success.queue", durable = "true"),
			exchange = @Exchange(name = "pay.direct"),
			key = "pay.success"
	))
	public void listenPaySuccess(Long orderId){
		orderService.markOrderPaySuccess(orderId);
	}
}